﻿using DeZhen.Core.Framework.Business.Ioc;
using DeZhen.Core.Framework.Entity;
using DeZhen.Core.Template.Domain.Entity.TableEntity;
using DeZhen.Core.Template.Domain.IRepository;
using DeZhen.Core.Template.Domain.Service.IService;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace DeZhen.Core.Template.Domain.Service.Impl
{
    /// <summary>
    /// 只需要此特性即可将自身注册到容器中
    /// </summary>
    [Service(ServiceLifetime.Transient)]
    public class UserServiceImpl:IUserService
    {
        [Autowired]
        private IUserRepository _userRepository;
        public UserServiceImpl(IAutowiredPlatform autowiredService)
        {
            autowiredService.Autowired(this);
        }
        public Task<int> CreateUserInfoToDataBase(UserInfo entity)
        {
            return _userRepository.CreateUserInfoToDataBase(entity);
        }

        public Task<bool> CreateUserInfoToRedis(string key, UserInfo entity)
        {
            return _userRepository.CreateUserInfoToRedis(key, entity);
        }

        public Task<List<UserInfo>> GetUserInfoFromDataBaseAsync()
        {
            return _userRepository.GetUserInfoFromDataBaseAsync();
        }

        public Task<UserInfo> GetUserInfoFromRedisAsync(string key)
        {
            return _userRepository.GetUserInfoFromRedisAsync(key);
        }
    }
}
